/***********************************************************************/
/*                                                                     */
/*  FILE        :resetprg.c                                            */
/*  DATE        :Thu, May 13, 2010                                     */
/*  DESCRIPTION :initialize for C language.                            */
/*  CPU GROUP   :62P                                                   */
/*                                                                     */
/*  This file is generated by Renesas Project Generator (Ver.4.17).    */
/*                                                                     */
/***********************************************************************/
/*********************************************************************
*
* Device     : M16C/62P,62PT
*
* File Name  : resetprg.c
*
* Abstract   : Initialize for C language.
*
* History    : 2.00  (2009-01-26)  [Hardware Manual Revision : 2.41]
*
* Copyright(c) 2009 Renesas Technology Corp.
*               And Renesas Solutions Corp.,All Rights Reserved. 
*
*********************************************************************/
#include "sfr62p.h"
#include "typedefine.h"
#include "resetprg.h"

extern _UINT    _stack_top,_istack_top;
//DEF_BANKSELECT;
DEF_SBREGISTER;

#pragma entry start
void start(void);
extern void initsct(void);
extern void _init(void);
void exit(void);
void main(void);

#pragma section program interrupt 

void start(void)
{
	_isp_	= &_istack_top; 	// set interrupt stack pointer
	prcr	= 0x02U;		// change protect mode register
	pm0	= 0x00U;		// set processor mode register
	prcr	= 0x00U;		// change protect mode register
	_flg_	= __F_value__;	// set flag register
#if __STACKSIZE__!=0
	_sp_	= &_stack_top; 	// set user stack pointer
#endif
	_sb_	= 0x400U;	// 400H fixation (Do not change)

	// set variable vector's address
	_asm("	ldc	#((topof vector)>>16)&0FFFFh,INTBH");
	_asm("	ldc	#(topof vector)&0FFFFh,INTBL");

	initsct();		// initlalize each sections

#if __HEAPSIZE__ != 0
	heap_init();		// initialize heap 
#endif
#if __STANDARD_IO__ != 0
	_init();			// initialize standard I/O
#endif
	_fb_ = 0U;	// initialize FB registe for debugger
	main();			// call main routine

	exit();		// call exit
}

void exit(void)
{
	while(1)
	{
		;		// infinite loop
	}
}

